<?php
/**
 * User: onwer
 * Date: 11-12-28
 * Time: 上午12:02
 */

require 'lib/lib.php';
include 'islogin.php';

$actinfo='';
$include_src='';
$f_title='';
$filed= new Filed();
$act=isset($_GET['act'])?$_GET['act']:'';
$tid=isset($_GET['tid'])?$_GET['tid']:0;
$fid=isset($_GET['fid'])?$_GET['fid']:0;

switch ($act){
    case 'add':{
        if(isset($_POST['fname']) && isset($_POST['fdesc'])&&isset($_POST['ftype'])&&isset($_GET['tid'])){

            if($filed->add($_POST['fname'],$_POST['fdesc'],$_POST['ftype'], $_GET['tid'])){
                $actinfo=Fun::echoinfo('添加成功！','succeed');
            }else{
                $actinfo=Fun::echoinfo($filed->errorinfo[2],'error');
            }

        }
        $include_src = 'filed_add.php';
        break;
    }
    case 'alt':{
        $curfiled=$filed->queryfid($fid);
        if(isset($_POST['fname'])&&isset($_POST['fdesc'])){
            if($filed->alt($_POST['fname'],$_POST['fdesc'],$_POST['ftype'],$curfiled[0]['id'],$tid)){
                $actinfo = Fun::echoinfo('修改成功','succeed');
            }else{
                $actinfo=Fun::echoinfo($filed->errorinfo[2],'error');
            }

        }
        $include_src = 'filed_alt.php';
        break;
    }
    case 'del':{
        if( isset($_GET['confirm'])&&$_GET['confirm']==='yes'){
            if($filed->del($tid,$fid)){
                $actinfo = Fun::echoinfo('删除成功','succeed');
            }else{
                $actinfo=Fun::echoinfo($filed->errorinfo[2],'error');
            }

        }
        $include_src = 'filed_del.php';
        break;
    }
    default:{
        $include_src = 'filed_show.php';
    }
}

include ADMIN_ABS_TPL_SRC.'index.php';

